package com.zhangmeng.tools.languages;

import java.util.regex.Pattern;

/**
 * @author : 芊芊墨客
 * @version : 1.0
 * @date : 2023-06-12 17:17
 */
public class ProcessYML {

    public static final String[] KEYWORDS = new String[] {
            "true", "false", "yes", "no", "null",""
    };

    public static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b";
    public static final String NUMBER_PATTERN = "\\b\\d+\\b";
    public static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\"";
    public static final String COMMENT_PATTERN = "\\s*#.*";
    public static final String ANCHOR_ALIAS_PATTERN = "^(&|\\*)[a-zA-Z0-9_-]+$";
    public static final String TAG_PATTERN = "!\\S+";
    public static final String DOCUMENT_MARKER_PATTERN = "^(---|\\.\\.\\.)$";
    public static final String DIRECTIVE_PATTERN = "^%.+$";
    public static final String VARIABLE_PATTERN = "\\$\\{.+?\\}";

    public static final Pattern PATTERN = Pattern.compile(
            "(?<KEYWORD>" + KEYWORD_PATTERN + ")"
                    + "|(?<NUMBER>" + NUMBER_PATTERN + ")"
                    + "|(?<STRING>" + STRING_PATTERN + ")"
                    + "|(?<COMMENT>" + COMMENT_PATTERN + ")"
//                    + "|(?<ANCHOR_ALIAS>" + ANCHOR_ALIAS_PATTERN + ")"
                    + "|(?<TAG>" + TAG_PATTERN + ")"
//                    + "|(?<DOCUMENT_MARKER>" + DOCUMENT_MARKER_PATTERN + ")"
                    + "|(?<DIRECTIVE>" + DIRECTIVE_PATTERN + ")"
                    + "|(?<VARIABLE>" + VARIABLE_PATTERN + ")"
    );


}
